<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@include file="/jsp/common/head.jsp"%>

<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>订单管理页面 >> 订单添加页面</span>
    </div>
    <div class="providerAdd">
        <form id="billForm" name="billForm" method="post" action="${pageContext.request.contextPath }/bill/add">
            <!--div的class 为error是验证错误，ok是验证成功-->
            <input type="hidden" name="method" value="add">
            <div class="">
                <label for="billCode">订单编码：</label>
                <input type="text" name="billcode" class="text" id="billCode" value="">
                <!-- 放置提示信息 -->
                <font color="red"></font>
            </div>
            <div>
                <label for="productName">商品名称：</label>
                <input type="text" name="productname" id="productName" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="productUnit">商品单位：</label>
                <input type="text" name="productunit" id="productUnit" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="productCount">商品数量：</label>
                <input type="text" name="productcount" id="productCount" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="totalPrice">总金额：</label>
                <input type="text" name="totalprice" id="totalPrice" value="">
                <font color="red"></font>
            </div>
            <div>
                <label >供应商：</label>
                <select name="providerid" id="providerId">
                    <option value="0">==请选择==</option>
                </select>
                <font color="red"></font>
            </div>
            <div>
                <label >是否付款：</label>
                <input type="radio" name="ispayment" value="1" checked="checked">未付款
                <input type="radio" name="ispayment" value="2" >已付款
            </div>
            <div class="providerAddBtn">
                <input type="submit" name="add" id="add" value="保存">
                <input type="button" id="back" name="back" value="返回" >
            </div>
        </form>
    </div>
</div>
</section>
<%@include file="/jsp/common/foot.jsp" %>
<script>

    //页面加载的时候加载供应商信息
    $.ajax({
        url:"/provider/list",
        success:function (data) {
            //console.log(data);

            //创建一个字符串变量
            var optins = "";

            //遍历数组
            for(var i = 0 ; i < data.length ; i++){
                //把数组中的每一个元素的id和名称拼接到下拉项option标签中
                optins += "<option value='"+data[i].id+"'>"+data[i].proname+"</option>";
            }
            //把创建的所有的option标签添加到select表的后面
            $("#providerId").append(optins);
            $("#providerId").var(${bill.providerid})
        }
    })
</script>